#include <fstream>
#include "DefaultPersistStorage.h"

DefaultPersistStorage::DefaultPersistStorage(std::string name): PersistStorage(name)
{
    Load();
}

std::string DefaultPersistStorage::Read(std::string field)
{
    return configObj[field].as<std::string>();
}

void DefaultPersistStorage::Write(std::string field, std::string value)
{
    configObj[field] = value;
}

void DefaultPersistStorage::Save()
{
    std::ofstream fout("config.yaml");
    fout << configObj;
    fout.close();
}

void DefaultPersistStorage::Load()
{
    configObj = YAML::LoadFile("config.yaml");
}